package com.jp.code;

import java.util.Arrays;

public class Java8Test {
    public static void t1() {
        // parallelPrefix

        int[] ones = new int[10];


        Arrays.fill(ones, 1);

        Arrays.parallelPrefix(ones, Integer::sum);


        System.out.println(Arrays.toString(ones));

    }


    public static void t2() {
        // String join
        String authors = String.join(", ", "Raoul", "Mario", "Alan");
        System.out.println(authors);
    }


    public static void t3() {
        // 并行排序
        int[] ones = new int[]{9, 0, 4, 2, 3, 4, 5, 6, 7, 23};

        Arrays.parallelSort(ones);

        System.out.println(Arrays.toString(ones));
    }

    public static void t4() {
        int selectData = 23;
        // 二分搜索
        int[] ones = new int[]{9, 0, 4, 2, 3, 4, 5, 6, 7, 23};
        int binarySearch = Arrays.binarySearch(ones, selectData);


        int one = ones[binarySearch];

        if (selectData == one) {
            System.out.println(selectData + " == 相等");
        }
    }





    public static void main(String[] args) {
        t1();
        t2();
        t3();
        t4();
    }
}
